<template>
  <div>
    <el-form ref="ruleForm" :rules="rules" :model="form" label-width="100px">
      <el-form-item label="存储" prop="NAME">
        <el-input v-model="form.NAME"></el-input>
      </el-form-item>
      <el-form-item label="光口数" prop="PORT">
        <el-input v-model="form.PORT"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >立即创建</el-button
        >
        <el-button type="info" @click="resetForm('ruleForm')">重置</el-button>
        <el-button style="float:right" @click="closeDialog">关闭</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        NAME: "",
        PORT: "",
      },
      rules: {
        NAME: [{ required: true, message: "请输入存储名称", trigger: "blur" }],
        PORT: [{ required: true, message: "请输入光口数", trigger: "blur" }],
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    closeDialog(){
        this.$emit('closeDislog')
    },
  },
};
</script>

<style lang="scss" scoped></style>
